//
//  CALayer+Resize.m
//  Pay
//
//  Created by steve on 15-1-13.
//  Copyright (c) 2015年 steve. All rights reserved.
//

#import "CALayer+Util.h"

@implementation CALayer (Util)

- (UIImage *) toImage {
  UIGraphicsBeginImageContext(self.bounds.size);
  [[UIColor clearColor] set];
  CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0,
                                                              0,
                                                              self.bounds.size.width,
                                                              self.bounds.size.height));
  
  [[self presentationLayer] renderInContext:UIGraphicsGetCurrentContext()];
  UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  return image;
}

@end
